package cn.edu.zut.cs.Controller;

import cn.edu.zut.cs.Business.CheckapplyService;
import cn.edu.zut.cs.Business.UserService;
import cn.edu.zut.cs.Model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 导航栏跳转控制
 */
@Controller
public class pageController {
    @Autowired
    UserService userService;
    @Autowired
    CheckapplyService checkapplyService;

    @RequestMapping("/personpag")
    public String personpage(){
        return "personpage";
    }

    @RequestMapping("/firendspage")
    public String firendspage(){
        return "friendspage";
    }

    @RequestMapping("/findfriend")
    public String findfirends(String username,Model model){
        List<User> userList=checkapplyService.queryByreponsedper(username);
        model.addAttribute("applylists",userList);
        return "findfriends";
    }

    @RequestMapping("/main")
    public String main(){
        return "main";
    }

//    @RequestMapping("/myroom")
//    public String myroom(){
//        return "myroom";
//    }
    @RequestMapping("/myinfo")
    public String myinformation(HttpSession session, Model model){
        //获取登录对象
        User user= (User) session.getAttribute("userInfo");
        String username=user.getUsername();
        User user1 = userService.findbyusernameandpwd(username);
        model.addAttribute("uu",user1);
        return "myinformation";
    }
}
